﻿<view:NavigationAwarePage x:Class="WPForms.Phone.View.Form"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"                        
    xmlns:view="clr-namespace:PhoneUtils.View;assembly=PhoneUtils"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"    
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:prismInteractivity="clr-namespace:Microsoft.Practices.Prism.Interactivity;assembly=Microsoft.Practices.Prism.Interactivity"    
    xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
    xmlns:abu="clr-namespace:AppBarUtils;assembly=AppBarUtils"
    mc:Ignorable="d"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    d:DesignHeight="728" d:DesignWidth="480"
    DataContext="{Binding Source={StaticResource ViewModelLocator}, Path=Form}">
    <!-- Application bar -->
    <view:NavigationAwarePage.ApplicationBar>
        <shell:ApplicationBar>                        
            <shell:ApplicationBarIconButton IconUri="Resources/AppBarIcons/upload.png" Text="upload"/>
            <shell:ApplicationBarIconButton IconUri="Resources/AppBarIcons/delete.png" Text="delete"/>
        </shell:ApplicationBar>
    </view:NavigationAwarePage.ApplicationBar>
    <i:Interaction.Behaviors>        
        <abu:AppBarItemCommand Id="delete" Command="{Binding DeleteCommand}"/>
        <abu:AppBarItemCommand Id="upload" Command="{Binding UploadCommand}"/>
    </i:Interaction.Behaviors>
    
    <Grid x:Name="LayoutRoot" Background="Transparent">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!--TitlePanel contains the name of the application and page title-->
        <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
            <TextBlock x:Name="ApplicationTitle" Text="{StaticResource AppName}" Style="{StaticResource PhoneTextNormalStyle}"/>
            <StackPanel Margin="9,-7,0,0" Orientation="Horizontal">
                <TextBlock Margin="0" Text="{Binding CurrentForm.Name}"  Style="{StaticResource PhoneTextTitle2Style}"/>
                <TextBlock Margin="0" Text="." Style="{StaticResource PhoneTextTitle2Style}"/>
                <TextBlock Margin="0" Text="{Binding CurrentSection.Name}" Style="{StaticResource PhoneTextTitle2Style}"/>
            </StackPanel>             
        </StackPanel>

        <!--ContentPanel - place additional content here-->
        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
            <Grid.RowDefinitions>
                <RowDefinition Height="1*"/>
                <RowDefinition Height="Auto"/>                
            </Grid.RowDefinitions>
            <ScrollViewer Grid.Row="0">
                <ItemsControl ItemsSource="{Binding CurrentSection.Children}">
                    <ItemsControl.ItemTemplate>
                        <DataTemplate>
                            <view:TypeDataTemplateSelector HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch" Content="{Binding ., Converter={StaticResource ViewModelConverter}}"/>
                        </DataTemplate>
                    </ItemsControl.ItemTemplate>
                </ItemsControl>
            </ScrollViewer>            
        </Grid>
    </Grid>
</view:NavigationAwarePage>
